import tensorflow as tf
import os
from common import show_picture

if __name__ == '__main__':
    os.environ["TF_CPP_MIN_LOG_LEVEL"] = '2'
    image_path = './lenna.png'

    # 读取图片数据
    image = tf.io.read_file(image_path)
    image = tf.image.decode_png(image)

    show_picture(image, 'lenna.png')

    grey_image = tf.image.rgb_to_grayscale(image)
    show_picture(grey_image, 'grey_image_lenna.png')
    grey_image = tf.image.encode_png(grey_image)
    tf.io.write_file('grey_image_lenna.png', grey_image)